package com.pet.review.controller;


import com.pet.common.domain.Result;
import com.pet.review.domain.dto.ReviewDTO;
import com.pet.review.service.IReviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品评论表 前端控制器
 * </p>
 *
 * @author Cookies
 * @since 2024-07-11
 */
@Api(tags = "评论服务接口")
@RestController
@RequestMapping("/reviews")
@RequiredArgsConstructor
public class ReviewController {
    private final IReviewService reviewService;

    @PostMapping
    @ApiOperation("用户添加评论")
    public Result addReviewByUser(@RequestBody ReviewDTO reviewDTO) {
        return reviewService.addReviewByUser(reviewDTO);
    }

    @GetMapping("/item/{itemId}")
    @ApiOperation("根据商品id查询评论列表")
    public Result getReviewListByItem(@PathVariable Integer itemId) {
        return reviewService.getReviewListByItem(itemId);
    }
}
